#!/usr/bin/env python
# encoding: utf-8
s = '''
@author: heshengjin-何胜金
@contact: 2356899074@qq.com
@software: pycharm
@file: generatorTest.py
@time: 2018/12/23 0023 16:28
@desc:generator列表生成器-保留的仅仅是算法，使用的时候才开始
      （x for x in range(1,100)）
'''

if __name__ == '__main__':
    # <class 'range'>
    print(type(range(1, 2)))
    for x in range(0,10):
        print(x)

    # <class 'list'>
    print(type(list(range(1,2))))

    # <class 'tuple'>
    print(type(tuple(range(1,2))))


    # 转list
    # list:[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
    generator_list = [x for x in range(10)]
    print(generator_list)

    # *****************************
    # generator:range转列表生成器（特殊）
    # <generator object <genexpr> at 0x000001EDCD2C3228>
    # *****************************
    generator_ex = (x for x in range(10))
    print(generator_ex)
    for i in generator_ex:
        print(i)
